﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityModels;

using DataAccessLayer;

namespace BusinessLayer
{
    class EventControl
    {

        public bool CreateEvent(Event ev, List<Location> locations, List<DateTime> dates, List<TimeSpan> times)
        {
            return DataAccess.Instance.AddEvent(ev, locations, dates, times);       
        }

        public bool UpdateEvent(Event ev, List<Location> locations, List<DateOptions> dates, List<TimeOptions> times)
        {
          
            return DataAccess.Instance.UpdateEvent(ev, locations, dates, times);
         
        }

        public bool  DeleteEvent(Event ev) {
            if (ev.idevent == 0) { throw new Exception("Failure with the ID of the event"); }
           return DataAccess.Instance.DeleteEvent(ev);
          
        }
        
        public Event GetEvent(int id) {
            if (id == 0) { throw new Exception("Failure with the ID of the event"); }
            return DataAccess.Instance.GetEvent(id);
         
        }
        
        public List<Event> GetEvents(User us, Byte b) {
            return DataAccess.Instance.GetEvents(us,b);      
        }

        public bool EventExists(Event ev) 
        {
            if (ev.idevent == 0) { throw new Exception("Failure with the ID of the event"); }
            return  DataAccess.Instance.EventExists(ev);
        }

        public bool LocationVoted(User us, Event ev)
        {
            return DataAccess.Instance.LocationVoted(us, ev);

        }
        public bool DateVoted(User us, Event ev)
        {
            return DataAccess.Instance.DateVoted(us, ev);

        }
        public bool TimeVoted(User us, Event ev)
        {
            return DataAccess.Instance.TimeVoted(us, ev);

        }

        public bool VoteLocation(User us, Event ev, Location lo)
        {
            return DataAccess.Instance.VoteLocation(us, ev, lo);
        }

        public bool VoteDate(User us, Event ev, DateTime d)
        {
            return DataAccess.Instance.VoteDate(us, ev, d);
        }
        public bool VoteTime(User us, Event ev, TimeSpan t)
        {
            return DataAccess.Instance.VoteTime(us, ev, t);
        }
        public bool VotingFinished(Event ev) {

            return DataAccess.Instance.VotingFinished(ev);
        }
        public Location GetLocationVoted(Event ev) {

            return DataAccess.Instance.getLocationVoted(ev);
        }

        public TimeSpan GetTimeVoted(Event ev)
        {

            return DataAccess.Instance.getTimeVoted(ev);
        }

        public DateTime GetDateVoted(Event ev)
        {

            return DataAccess.Instance.getDateVoted(ev);
        }
        public bool Attend(User us, Event ev) {

            return DataAccess.Instance.Attend(us, ev);
        }
        public bool NotAttend(User us, Event ev)
        {

            return DataAccess.Instance.NotAttend(us, ev);
        }
        public bool Attending(User us, Event ev)
        {

            return DataAccess.Instance.Attending(us, ev);
        }
        public bool Invite(User us, Event ev)
        {

            return DataAccess.Instance.Invite(us, ev);
        }

        public List<Location> getLocations(Event ev) {
            return DataAccess.Instance.getLocations(ev);
        
        }
        public List<DateOptions> getDates(Event ev)
        {
            return DataAccess.Instance.getDates(ev);

        }
        public List<TimeOptions> getTimes(Event ev)
        {
            return DataAccess.Instance.getTimes(ev);

        }
    }
}
